// pages/operation/clueManage/tryListenDetail/index.js
import { ClassModel } from "../../../../api/api-work/classModel.js"
const classModel = new ClassModel()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    query: {},
    time: "",
    classRoom: "",
    description: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const param = JSON.parse(options.param)
    this.setData({
      query: param,
      time: param.classDate + " " + param.classStartTime + " ~ " + param.classEndTime,
      classRoom: param.classRoomName == null ? '-' : param.classRoomName,
      description: param.description == null ? '' : param.description
    })
    console.log("试听确认：", this.data.query)
  },

  // 确认跟班试听
  confirmListen() {
    classModel.addStudentApi({ classDate: `${this.data.query.classDate} 00:00:00`, cofId: this.data.query.cofId, temp: 3, orderNo: this.data.query.orderNo, ids: [{ id: this.data.query.studId, courseId: this.data.query.courseId }] }).then(res => {
      wx.navigateBack()
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})